<template>
  <div class="container" ref="mainCon">
    <topTitle :titleText="titleText"></topTitle>

    <div class="mainCon">
      <el-row class="toolbar searchInputWidth" style="padding-bottom: 0">
        <el-form :inline="true" :model="filterField" ref="searchConditions">
          <el-col :lg="8" :xl="6">
            <el-form-item label="区域" class="row-padding-bottom">
              <el-cascader
                ref="manageArea"
                v-model="areaId"
                :options="areasOptions"
                @change="getAreaId"
                clearable
                filterable
                :props="{ checkStrictly: true }"
                :append-to-body="false"
              ></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :lg="8" :xl="6">
            <el-form-item label="行业" class="row-padding-bottom">
              <el-select
                v-model="filterField.industryId"
                filterable
                placeholder="请选择"
                clearable
                :popper-append-to-body="false"
              >
                <el-option
                  v-for="item in industryOptions"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <template v-if="advanced">
            <el-col :lg="8" :xl="6">
              <el-form-item
                label="纠纷类型"
                class="row-padding-bottom"
                :popper-append-to-body="false"
              >
                <el-select v-model="filterField.typeId" clearable>
                  <el-option label="拖欠工资" value="01"></el-option>
                  <el-option label="劳务纠纷" value="02"></el-option>
                  <el-option label="违法事件" value="03"></el-option>
                  <el-option label="其他" value="04"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :lg="8" :xl="6">
              <el-form-item label="状态" class="row-padding-bottom">
                <el-select
                  v-model="filterField.status"
                  clearable
                  :popper-append-to-body="false"
                >
                  <el-option label="待处理" value="01"></el-option>
                  <el-option label="已处理" value="03"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :lg="8" :xl="6">
              <el-form-item label="项目名称" class="row-padding-bottom">
                <el-input
                  v-model="filterField.searchText"
                  type="text"
                  placeholder="输入项目名称"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
          </template>
          <el-col :lg="8" :xl="6">
            <el-form-item label="">
              <a
                @click="toggleAdvanced"
                style="margin-left: 40px; color: #409eff; cursor: pointer"
                class="btnColor"
              >
                {{ advanced ? '收起' : '展开' }}
                <i
                  :class="advanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
                ></i>
              </a>
              <el-button
                type="primary"
                icon="icon iconfont iconchazhao1"
                @click="searchList"
                class="searchBtn"
              >
                <span>搜索</span>
              </el-button>
            </el-form-item>
            <el-form-item>
              <exportBtn
                :dataLen="tableList.length"
                :filterField="filterField"
                api="api-s/report/export_JC_CS_RIGHTS_COMPLAINT_HANDLE"
              ></exportBtn>
            </el-form-item>
          </el-col>
          <!--
                    <el-form-item>
                        <el-button type="primary" icon="icon iconfont iconchazhao1" @click="searchList" class="commonBtn"></el-button>
                    </el-form-item> -->
        </el-form>
      </el-row>
      <div class="spacing"></div>
      <div
        ref="tableBox"
        :class="hiddleToolBar ? 'tableBoxCur tableBox' : 'tableBoxCur'"
      >
        <el-table
          ref="tableBox1"
          @sort-change="sortChange"
          :max-height="tableHeight"
          :data="tableList"
          v-loading="loading"
          :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          highlight-current-row
          stripe
          style="border: 1px solid #dfe6ec"
        >
          <el-table-column
            prop="complainantName"
            label="投诉人"
            min-width="120px"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            prop="tel"
            label="投诉人联系方式"
            align="center"
            :formatter="formatTd"
            min-width="140px"
          ></el-table-column>
          <el-table-column
            prop="createTime"
            label="投诉时间"
            sortable="custom"
            align="center"
            :formatter="formatTd"
            min-width="180px"
          ></el-table-column>
          <el-table-column
            prop="typeName"
            label="纠纷类型"
            align="center"
            :formatter="formatTd"
            min-width="120px"
          ></el-table-column>
          <!-- <el-table-column prop="projectName" label="项目名称" align="center" :formatter=formatTd></el-table-column>  -->
          <el-table-column prop="projectName" label="项目名称" width="230">
            <template slot-scope="scope">
              <copyText
                :tableIndex="scope.$index"
                :copyTextName="scope.row.projectName"
                :columnName="'projectName'"
              ></copyText>
            </template>
          </el-table-column>
          <!-- <el-table-column prop="content" label="纠纷内容" align="center" :formatter=formatTd  :show-overflow-tooltip="true"></el-table-column> -->
          <el-table-column prop="content" label="纠纷内容" width="230">
            <template slot-scope="scope">
              <copyText
                :tableIndex="scope.$index"
                :copyTextName="scope.row.content"
                :columnName="'content'"
              ></copyText>
            </template>
          </el-table-column>
          <el-table-column
            prop="statusDesc"
            label="状态"
            align="center"
            :formatter="formatTd"
            min-width="120px"
          ></el-table-column>
          <el-table-column
            prop="deal"
            label="操作"
            align="left"
            :formatter="formatTd"
            width="80px"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-link
                type="primary"
                @click="toDetail(scope.$index, scope.row)"
                v-hasBtn="['rightsList:update', 'rightsList:add']"
                >处理</el-link
              >
              <!-- <el-link type="primary" v-else>--</el-link> -->
            </template>
          </el-table-column>
          <!-- 表格数据为空时，页面显示 -->
          <div slot="empty" v-show="isShow">
            <emptyTable emptyText="暂无相关投诉举报数据"></emptyTable>
          </div>
        </el-table>

        <!-- filterField为搜索条件 -->
        <!-- getTableList为获取子组件的数据 -->
        <Pagination
          ref="pagination"
          @getpageSize="getpageSize"
          @getpageNo="getpageNo"
          @getList="getTableList"
          :filterField="filterField"
          :requestUrl="requestUrl"
        ></Pagination>
      </div>
    </div>
  </div>
</template>

<script>
import scrollTable from '@/mixin/scrollTable.js'
import { mapActions, mapState } from 'vuex'

export default {
  name: 'rightsList',
  mixins: [scrollTable],
  data() {
    return {
      titleText: '投诉举报',
      advanced: false,
      //表格数据
      tableList: [],
      requestUrl: 'api-r/rightscomplainthandle/expand/listbypage',
      date: [],
      //搜索条件
      filterField: {
        searchText: '', //姓名或身份证号
        typeId: '',
        status: '',
        areaId: '', //区域
        industryId: '',
      },
      pageSize: 20,
      pageNo: 1,
      isShow: false, //列表加载
      loading: false, //暂时关闭loading
      areaId: '', //区域
      // isShowUpdete:""
    }
  },
  computed: { ...mapState(['areasOptions', 'industryOptions']) },
  created() {
    this.filterField.searchText = this.$route.query.projectName
      ? this.$route.query.projectName
      : ''
    this.filterField.status = this.$route.query.status
      ? this.$route.query.status
      : ''
    this.areaId = this.$route.query.areaId ? this.$route.query.areaId : ''
    this.filterField.areaId = this.areaId
    this.$nextTick(function () {
      this.$refs.pagination.getTableListData()
    })
    //获取区域
    this.getAreas({ areaId: this.$store.state.areaInfoArr.areaId })
    //获取行业
    this.getIndustry({})
    // this.isShowUpdete = this.$store.state.buttonLimitsArr.indexOf('rightsList:update') > -1 ||
    //                     this.$store.state.buttonLimitsArr.indexOf('rightsList:add') > -1 ;
  },
  activated() {
    this.$nextTick(function () {
      this.$refs.pagination.getTableListData(this.pageNo, this.pageSize)
    })
  },
  methods: {
    toggleAdvanced() {
      this.advanced = !this.advanced
    },
    getpageSize(val) {
      this.pageSize = val
    },
    getpageNo(val) {
      this.pageNo = val
    },
    ...mapActions(['getAreas', 'getIndustry']),
    toDetail(index, row) {
      this.$router.push({
        path: '/home/events/dealDispute',
        name: 'dealDispute',
        query: {
          id: row.id,
        },
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/events/rightsList',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
    getTableList(data) {
      this.tableList = data
      this.loading = false
      if (this.tableList.length < 1) {
        this.isShow = true
      }
    },
    // 搜索
    searchList() {
      this.$refs.pagination.getTableListData()
    },
    toDeal() {
      this.$router.push({ name: 'dealDispute' })
    },
    //获取选中的区域最后一级id
    getAreaId() {
      var areaId = this.areaId[this.areaId.length - 1]
      this.filterField.areaId = areaId
    },
  },
}
</script>

<style lang="less" scoped>
.mainCon {
  top: 198px;
}
.el-tooltip__popper {
  max-width: 30% !important;
  word-break: break-all;
}
@media only screen and (max-width: 1366px) {
  /deep/.searchInputWidth .el-form--inline .el-form-item__label {
    width: 80px;
  }
}
@import '../../../static/css/filterArea.less';
</style>
